<?php

namespace app\controller\admin\dark;

use app\model\api\dark\DarkRecord;
use laytp\controller\Backend;

/**
 * Class Record
 * @package app\controller\admin\dark
 */
class Position extends Backend
{
    /**
     * api_log模型对象
     * @var \app\model\api\Log
     */
    protected $model;
    protected $hasSoftDel=0;//是否拥有软删除功能

    public $orderRule = ['sort' => 'desc', 'id' => 'asc'];

    protected $noNeedLogin = []; // 无需登录即可请求的方法
    protected $noNeedAuth = ['index', 'info']; // 无需鉴权即可请求的方法

    public function _initialize()
    {
        $this->model = new DarkRecord();
    }


    //查看
    public function index(){
        $where = $this->buildSearchParams();
        $order = $this->buildOrder();
        $allData = $this->request->param('all_data');
        $data = $this->model->where($where)->where(array('type' => 2))->order($order)->with(['author']);
        if($allData){
            $data = $data->select()->toArray();
        }else{
            $limit = $this->request->param('limit', 10);
            $data = $data->paginate($limit)->toArray();
        }
        return $this->success('数据获取成功', $data);
    }




}